<layout name="layout" />
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<script src="__PUBLIC__/common/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<title></title>
		<script type="text/javascript">
			$(function(){
				var img = '';
//				$('#ups').change(function(){
//					$.post("{:U('ajax_up')}",
//				    {
//				        
//				    },
//				        function(data,status){
//				        alert("数据: \n" + data + "\n状态: " + status);
//				    })
//				});
				
				$('#ups').change(function(){
					var form = $('#lunbo_form')[0];
					var formdata1 = new FormData(form);
//					console.log(formdata1);
					
					$.ajax({  
				        type : "post",  
				        url : "{:U('ajax_up')}",  
				        data : formdata1,
				        async: false,  
				        cache: false,  
				        contentType: false,  
				        processData: false,
				        success : function(data) {  
				            if(data){
				            	//alert('提交成功！');
				            	$('#img_post').val(data);
				            	var img = "<img width='200' height='200' src='__UPLOADS__/" + data + "' />";
				            	$('.img').html(img);
				            } 
				        }  
					}); 
				});
				
					
			});
		</script>
	</head>
	<body>
		<form id="lunbo_form" action="{:U('lunbo_insert')}" method="post" enctype="multipart/form-data">
			name:<input type="text" name="name" value="" />
			sort:<input type="text" name="sort" value="" />
			url:<input type="text" name="url" value="" />
			<input type="hidden" name="img" id="img_post" value="" />
			<div class="img">
				
			</div>
			<input type="file" name="ups" id="ups" value="" />
			<input type="submit" value="添加"/>
		</form>
	</body>
</html>
